<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "read_question".
 *
 * @property integer $id
 * @property integer $tnum
 * @property integer $read_content_id
 * @property string $content
 * @property string $answer
 * @property integer $type
 * @property integer $paragraph
 * @property integer $t_type
 *
 * @property ReadOption[] $readOptions
 * @property ReadContent $readContent
 */
class ReadQuestion extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'read_question';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['tnum', 'read_content_id', 'content', 'answer', 'type', 't_type'], 'required'],
            [['tnum', 'read_content_id', 'type', 'paragraph', 't_type'], 'integer'],
            [['content'], 'string'],
            [['answer'], 'string', 'max' => 20],
            [['read_content_id'], 'exist', 'skipOnError' => true, 'targetClass' => ReadContent::className(), 'targetAttribute' => ['read_content_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'tnum' => 'Tnum',
            'read_content_id' => 'Read Content ID',
            'content' => 'Content',
            'answer' => 'Answer',
            'type' => 'Type',
            'paragraph' => 'Paragraph',
            't_type' => 'T Type',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getReadOptions()
    {
        return $this->hasMany(ReadOption::className(), ['read_question_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getReadContent()
    {
        return $this->hasOne(ReadContent::className(), ['id' => 'read_content_id']);
    }
}
